package com.example.myapplication3.fragment;

import android.os.Bundle;

import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.myapplication3.R;

/**
 * A simple {@link Fragment} subclass.
 * Use the {@link SplashPage_1_Fragment#newInstance} factory method to
 * create an instance of this fragment.
 */
public class SplashPage_1_Fragment extends Fragment {

    // TODO: Rename parameter arguments, choose names that match
    // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
    private static final String ARG_IMGERES = "imgeRes";
    private static final String ARG_COLOR = "color";
    private static final String ARG_TEXT = "text";

    // TODO: Rename and change types of parameters
    private int mImageRes;
    private int mColor;
    private String mtext;

    public SplashPage_1_Fragment() {
        // Required empty public constructor
    }

    /**
     * Use this factory method to create a new instance of
     * this fragment using the provided parameters.
     *
     * @param imgeRes Parameter 1.
     * @param color Parameter 2.
     * @return A new instance of fragment SplashPage_1_Fragment.
     */
    // TODO: Rename and change types and number of parameters
    public static SplashPage_1_Fragment newInstance(int imgeRes, int color,String text) {
        SplashPage_1_Fragment fragment = new SplashPage_1_Fragment();
        Bundle args = new Bundle();
        args.putInt(ARG_IMGERES, imgeRes);
        args.putInt(ARG_COLOR, color);
        args.putString(ARG_TEXT, text);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            mImageRes = getArguments().getInt(ARG_IMGERES);
            mColor = getArguments().getInt(ARG_COLOR);
            mtext  = getArguments().getString(ARG_TEXT);
        }
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view =inflater.inflate(R.layout.fragment_splash_page_1_, container, false);
        ImageView imageView = view.findViewById(R.id.imageView);
        TextView textView =view.findViewById(R.id.textView);

        imageView.setImageResource(mImageRes);
        textView.setTextColor(mColor);
        textView.setText(mtext);
        // Inflate the layout for this fragment
        return view ;
    }
}